package com.apimarket.dao;

import com.apimarket.entity.DataPacket;
import com.apimarket.entity.Dataset;
import com.apimarket.entity.vo.DataSetAndPacketVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * @Description:
 * @Author ZXR
 * @Date 2021/7/6 15:59
 * @Version 1.0
 */
@Repository
public interface DataSetMapper {
    List<Map<Integer, String>> getTypeList();

    List<Dataset> findAll(Integer type, String name);

    void addDataset(Dataset dataset);

    @Delete("delete from dataset where id=#{id}")
    void deleteDataSet(String id);

    void updateDataset(Dataset dataset);

    void packetAdd(DataPacket packet);

    List<DataPacket> findPacketAll(String name,String datasetId);

    void updateDataPacket(DataPacket packet);

    @Delete("delete from data_packet where id=#{id}")
    int deletePacket(String id);

    DataSetAndPacketVo getDataSetDetailAndChildPackets(String id);

    @Select("select path from dataset where id=#{datasetId}")
    String getDataSetPathById(String datasetId);

    @Delete("delete from `data_packet` where dataset_id=#{id}")
    void deletePacketByDatasetId(String id);

    @Update("update dataset set download_num=download_num+1 where id=#{datasetId}")
    void addDownloadNum(String datasetId);
}
